package cn.hxzy.zyicon.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.util.Date;
import java.io.Serializable;
import java.util.List;

/**
 * (Resource)实体类
 *
 * @author makejava
 * @since 2020-08-13 11:34:07
 */
@Table
@Entity
@Data
public class Resource implements Serializable {

    /**
     * id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    /**
     * 名字
     */
    private String name;
    /**
     * 地址
     */
    private String url;
    /**
     * 父级id
     */
    private Integer pid;

    /**
     * 每次对象插入数据库就会有创建时间
     */
    @CreationTimestamp
    /**插入数据库之后此字段不让修改
     *
     */
    @Column(updatable = false)
    /**转成json字符串时的格式和时区
     *
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @UpdateTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    private Integer orderNumber;

    @Transient
    private List<Resource> son;
}